﻿
using MahApps.Metro.Controls;

namespace ZDK.Views
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : MetroWindow
    {
        Utilities.TextBoxAppender _logAppender;

        public MainWindow()
        {
            InitializeComponent();

            #region 绑定日志
            var logPattern = "%date [%thread] %-5level- %message%newline";
            var logAppender = new Utilities.TextBoxAppender()
            {
                TextBox = TBX_log,
                Layout = new log4net.Layout.PatternLayout(logPattern)
            };
            _logAppender = logAppender;
            ((log4net.Repository.Hierarchy.Hierarchy)log4net.LogManager.GetRepository()).Root.AddAppender(logAppender);
            #endregion
        }

        private void ClearLogBtnClicked(object sender, System.Windows.RoutedEventArgs e)
        {
            _logAppender.ClearLog();
        }
    }
}
